const util = require('./util');
module.exports = {
    readStream
};

/**
 * 读取Stream中的数据
 * @param readStream
 */
function readStream(readStream) {
    let cb = util.createPromiseCallback();
    let data = '';
    readStream.on('data', (chunk) => {
        data += chunk;
    })
    readStream.on('end', (chunk) => {
        cb(null, data);
    });
    readStream.on('error', cb);
    return cb.promise;
}